package com.tianpengtech.admin.fairorder;
import org.eclipse.jetty.security.UserAuthentication;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.Model;
import com.tianpengtech.admin.AbstractAdminController;
import com.tianpengtech.admin.InitInterceptor;
import com.tianpengtech.common.exception.ValidateException;
import com.tianpengtech.common.model.authenticate.Authenticate;
import com.tianpengtech.common.model.fairorder.FairOrder;

/**
* 路由配置地址：add("/admin/fairorder", FairOrderAdminController.class, "/admin/fairorder");
* 数据库映射地址：arp.addMapping(FairOrder.dao.tableName(),FairOrder.class);
*/
@Before(InitInterceptor.class)
public class FairOrderAdminController extends AbstractAdminController{

	@Override
	protected void config() {
		this.clazz=FairOrder.class;
		this.service=new FairOrderAdminServiceImpl();
	}

	@Override
	public void beforeAdd() {

	}

	@Override
	public void beforeAdd(Model< ? > model) throws ValidateException {

	}

	@Override
	public void beforeQueryById(Model<?> model, int id) {

	}

	@Override
	public void beforeUpdate(Model< ? > model) throws ValidateException {

	}

	@Override
	public void beforeDelete(Model< ? > model) {

	}

	@Override
	public void parsePageRecord(Object results) {
		FairOrder order = (FairOrder)results;
		String sql="select * from "+Authenticate.dao.tableName()+" where user_id=? limit 1";
		Authenticate authentication = Authenticate.dao.findFirst(sql,order.getLong(FairOrder.USER));
		order.set(FairOrder.USER, authentication.getStr(Authenticate.COMPANY_NAME));
		order.set(FairOrder.STATUS, order.status());
		order.set(FairOrder.OPT_TYPE, order.opt_type());
		order.set(FairOrder.TRADE_TYPE, order.trade_type());
		order.set(FairOrder.TOTAL_FEE, order.total_fee());
	}
}

	